package com.baidu.mpks.user.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.fartherp.shiro.ShiroFieldAccess;
import lombok.Data;

import java.util.Date;

@Data
public class User implements ShiroFieldAccess {

    public static final String STATUS_INVALID = "Close";
    public static final String STATUS_VALID = "Open";
    private Integer id;
    private String userId;
    private String password;
    private String roleIds;
    private String userName;
    private String trueName;
    private String gender;
    private String email;
    private String phoneNumber;
    private String avatar;
    private String userSecurity;
    private String code;
    private Integer isActive;
    private String status;
    private String createBy;
    private String updateBy;
    private String deleteBy;
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    private Date createTime;
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    private Date updateTime;
    private int deleteFlag;
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    private Date deleteTime;
    private String userInfo;
    private Date pwdUpdateTime;

    public User(String createBy, String updateBy, String deleteBy) {
        this.status = "Open";
        this.setCreateBy(createBy);
        this.setUpdateBy(updateBy);
        this.setDeleteBy(deleteBy);
        this.setAvatar("");
    }

    public User(String userId) {
        this(userId, userId, userId);
    }

    @Override
    public String unique() {
        return this.userId;
    }

    public User() {
        this.status = "Open";
    }
}
